﻿<%@ Page Language="C#" AutoEventWireup="true" Title="" %>

<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<link rel="stylesheet" href="<%=Page.ResolveClientUrl("~/")%>Manager/css/site_css.css"
    type="text/css">
<link rel="stylesheet" href='<%=Page.ResolveClientUrl("~/")%>Manager/css/table/<%=wlFrame.Common.TableSink%>/Css.css'
    type="text/css">

<script runat="server" language="C#">
    wlFrame.FileUpLoadCommon fc = new wlFrame.FileUpLoadCommon();//默认构造,放在PUBLIC,且按日期生成子目录
    string err = "";
    string filename = "";
</script>

<%   filename = Request["filename"];
    if ("" + Request["CMD"] == "delete")
    {
        try { System.IO.File.Delete(Server.MapPath(filename)); }
        catch (Exception e) { }
        filename = "";

    }
    if ("" + Request["CMD"] == "ok")
    {
        if (U_PhotoUrl.FileName != "")
        {
            fc.PromteExt = "jpg,png,gif,bmp";
            fc.MaxSize = 5096;
            if (fc.SaveImage(U_PhotoUrl.PostedFile, 450, 330, "H", true))//;// true 表示直接删除原来的图 ..  直接控制FILE,缩略图W宽,H高,按宽缩fc.SaveFile(U_PhotoUrl.PostedFile, false, false))
            {
                filename = "/public/" + fc.newFileName.Substring(0, 8) + "/s_" + fc.newFileName;
                try { System.IO.File.Delete(Server.MapPath("/public/" + fc.newFileName.Substring(0, 8) + "/" + fc.newFileName)); }
                catch (Exception e) { }
               // Response.Redirect("/manager/admin/uploadphoto/upParentPhoto.aspx?photoUrl=" + Request["photoUrl"] + "&photoImg=" + Request["photoImg"] + "&filename=" + filename);//跳回
               // Response.End();
               
            }
            else
            {
                err = fc.errorMsg;
            }
        }
    }
%>
<body>
    <table width="100%">
        <form runat="server">
        <input type="hidden" name="photoUrl" value="<%=Request["photoUrl"] %>" />
        <input type="hidden" name="photoImg" value="<%=Request["photoImg"] %>" />
        <tr class="table_none">
            <td style="color: Red; font-size: 14px" colspan="2">
                上传照片
            </td>
        </tr>
        <tr id="TopTr">
            <td class="table_none" rowspan="4">
                <img id="photo" src="<%=filename %>" height="220px" />
            </td>
            <td class="table_none">
                <input type="hidden" id="CMD" name="CMD" value="" />
                <asp:FileUpload ID="U_PhotoUrl" runat="server" contentEditable="false" CssClass="text_input"
                    Style="width: 60px" /><input type="button" value="上传查看效果" onclick="upload('ok');"><input
                        type="button" onclick="upload('delete');" value="删除图片">
                        <br />
                        <%=err %>
            </td>
        </tr>
        <tr class="table_none">
            <td class="table_none">
                <input type="button" value="--确定--" onclick="ok()" />
                <input type="button" value="--取消--" onclick="nook()" />
            </td>
        </tr>
        <tr class="table_none">
            <td style="color: Red; font-size: 10pt">
                操作说明：（1）通过点击【浏览按钮】请选择一张照片；<br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                注意：图片大小要小于5M；<br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                只能是jpg,png,gif,bmp类型;<br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                （2）点击【上传查看效果】完成文件上传并显示；<br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                (3）如果不正常，请点击【删除图片】；<br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                （4）如果正常，请点击【确定】完成上传任务。
            </td>
        </tr>
        </form>
    </table>
    <table width="100%">
    </table>
</body>

<script language="javascript">
 function upload(str)
 {
   document.getElementById("CMD").value=str;
   document.forms[0].submit();
   
 }
   function ok()
    {
              window.parent.document.getElementById("<%=Request["photoUrl"] %>").value="<%=filename %>";
              window.parent.document.getElementById("<%=Request["photoImg"] %>").src="<%=filename %>";
              window.close();
              window.parent.hidePopWin(true);
        
    }
     function nook()
    {
            
              window.close();
              window.parent.hidePopWin(true);
        
    }
</script>

<!-- window.top.adaptIFrameHeight(parseInt(window.location.hash.substring(1),10)); -->
